//
//  MechanicalDetailController.m
//  PASystem
//
//  Created by 刘沿 on 16/8/25.
//  Copyright © 2016年 czd. All rights reserved.
//
#import "xqzbViewController.h"

#import "MechanicalDetailController.h"
#import "TitleScrollView.h"
#import "ProjectViewController.h"
#import "InvestigateViewController.h"
#import "WorkTeamViewController.h"
#import "CompanyRecruitViewController.h"
#import "PreparedController.h"
#import "GroupGoingController.h"
#import "SummaryViewController.h"
#import "ScheduleController.h"
#import "PResultsViewController.h"
#import "ActivityResultController.h"
#import "GoHomeViewController.h"
#import "EvaluationExperienceController.h"
#import "DataArchivingController.h"
#import "ENDExperienceController.h"
#import "LastStageViewController.h"

#define DEVICEWIDTH [UIScreen mainScreen].bounds.size.width
#define DEVICEHEIGHT [UIScreen mainScreen].bounds.size.height
@interface MechanicalDetailController ()<UIScrollViewDelegate,selectControllerDelegate>

@property (nonatomic ,strong) TitleScrollView *headerView;
@property (nonatomic ,strong) UIViewController *currentVC;
@property (nonatomic ,strong) UIScrollView *mianScrollView;

@property (nonatomic,strong)ProjectViewController *proVC;
@property (nonatomic,strong)InvestigateViewController *InvesVC;
@property (nonatomic,strong)WorkTeamViewController *WorkTVC;
@property (nonatomic,strong)CompanyRecruitViewController *CompaVC;
@property (nonatomic,strong)PreparedController *PreVC;
@property (nonatomic,strong)GroupGoingController *gropuVC;
@property (nonatomic,strong)SummaryViewController *sumVC;
@property (nonatomic,strong)ScheduleController *SchVC;
@property (nonatomic,strong)PResultsViewController *PResVC;
@property (nonatomic,strong)ActivityResultController *actiVC;
@property (nonatomic,strong)DataArchivingController *dataVC;
@property (nonatomic,strong)GoHomeViewController *GoVC;
@property (nonatomic,strong)ENDExperienceController *ENDEXVC;
@property (nonatomic,strong)EvaluationExperienceController *EvaVC;
@property (nonatomic,strong)LastStageViewController *lastVC;
@property (nonatomic,strong)xqzbViewController *xqVC;

@property (nonatomic,strong) UIView *bg1;

//判断处于哪个阶段
@property (nonatomic,assign) NSInteger index;

//记录上一个选择的阶段的按钮
@property (nonatomic,strong) UIButton *lastBtn;

@end

@implementation MechanicalDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    UIView *bg1 = [[UIView alloc] init];
    bg1.backgroundColor = [UIColor blueColor];
    self.bg1 = bg1;
    [self.view addSubview:bg1];
    [bg1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@44);
    }];
    
//按钮的父亲
    UIView *bg2 = [[UIView alloc] init];
    bg2.backgroundColor = [UIColor colorWithRed:2/255.0 green:80/255.0 blue:187/255.0 alpha:1];
    [bg1 addSubview:bg2];
    [bg2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bg1.mas_top).mas_offset(5);
        make.left.equalTo(bg1.mas_left).mas_offset(10);
        make.right.equalTo(bg1.mas_right).mas_offset(-10);
        make.bottom.equalTo(bg1.mas_bottom).mas_offset(-5);
    }];
    bg2.layer.masksToBounds = YES;
    bg2.layer.cornerRadius = 5;
    
//创建按钮
    CGFloat W = (self.view.frame.size.width - 20)/4;
    NSArray *arr = @[@"准备阶段",@"实施阶段",@"结束阶段",@"后续阶段"];
    
    for (int i = 0; i < arr.count; i ++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setBackgroundColor:[UIColor colorWithRed:2/255.0 green:80/255.0 blue:187/255.0 alpha:1]];
        [btn setTitle:arr[i] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btn.frame = CGRectMake(i *W, 0, W, 34);
        
        if (i == 0) {
            self.lastBtn = btn;
            
            [self.lastBtn setBackgroundColor:[UIColor colorWithRed:160/255.0 green:194/255.0 blue:239/255.0 alpha:1]];
        }
        
        [btn.titleLabel setFont:[UIFont systemFontOfSize:16]];
        [btn addTarget:self action:@selector(StageBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [bg2 addSubview:btn];
    }
    
    
//设置上面滑动的视图
    self.headerView = [[TitleScrollView alloc] initWithArray:@[@"项目立项",@"先遣团考察",@"工作团队",@"企业招募",@"团队分组分工",@"行前准备和总结"]];
    self.index = 1;
    self.headerView.SelectDelegate = self;
    [self.view addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bg1.mas_bottom);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.height.equalTo(@44);
    }];
    
//下面滚动的视图 实现上线联动
    self.mianScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,88, DEVICEWIDTH,DEVICEHEIGHT - 64)];
    self.mianScrollView.delegate = self;
    self.mianScrollView.contentSize = CGSizeMake(DEVICEWIDTH*self.headerView.headArray.count, 0);
    self.mianScrollView.pagingEnabled = YES;
    self.mianScrollView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.mianScrollView];

//添加第一个视图
    self.proVC = [[ProjectViewController alloc]init];
    
    self.proVC.ID = self.ID;
    
    [self addChildViewController:self.proVC];
    self.proVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 46);
    [self.mianScrollView addSubview:self.proVC.view];
    
}
//阶段按钮点击方法
- (void)StageBtnClick:(UIButton *)btn{
    
    [self.lastBtn setBackgroundColor:[UIColor colorWithRed:2/255.0 green:80/255.0 blue:187/255.0 alpha:1]];
    
    [btn setBackgroundColor:[UIColor colorWithRed:160/255.0 green:194/255.0 blue:239/255.0 alpha:1]];
    
    self.lastBtn = btn;
    
    if ([btn.titleLabel.text isEqualToString:@"准备阶段"]) {
        [self.headerView removeFromSuperview];
        [self.mianScrollView removeFromSuperview];
        self.index = 1;
        self.headerView = [[TitleScrollView alloc] initWithArray:@[@"项目立项",@"先遣团考察",@"工作团队",@"企业招募",@"团队分组分工",@"行前准备和总结"]];
        self.headerView.SelectDelegate = self;
        [self.view addSubview:self.headerView];
        [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bg1.mas_bottom);
            make.left.equalTo(self.view.mas_left);
            make.right.equalTo(self.view.mas_right);
            make.height.equalTo(@44);
        }];
        
        //下面滚动的视图 实现上线联动
        self.mianScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,88, DEVICEWIDTH,DEVICEHEIGHT - 64)];
        self.mianScrollView.delegate = self;
        self.mianScrollView.contentSize = CGSizeMake(DEVICEWIDTH*self.headerView.headArray.count, 0);
        self.mianScrollView.pagingEnabled = YES;
        self.mianScrollView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:self.mianScrollView];
        
        //添加第一个视图
        self.proVC = [[ProjectViewController alloc]init];
        
        self.proVC.ID = self.ID;
        
        [self addChildViewController:self.proVC];
        self.proVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 46);
        [self.mianScrollView addSubview:self.proVC.view];
        
    }else if ([btn.titleLabel.text isEqualToString:@"实施阶段"]){
        
        [self.headerView removeFromSuperview];
        [self.mianScrollView removeFromSuperview];
        self.headerView = [[TitleScrollView alloc] initWithArray:@[@"团组启程",@"团组行程及安排",@"活动成果",@"团组返程",@"评价经验总结讨论"]];
        self.index = 2;
        self.headerView.SelectDelegate = self;
        [self.view addSubview:self.headerView];
        [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bg1.mas_bottom);
            make.left.equalTo(self.view.mas_left);
            make.right.equalTo(self.view.mas_right);
            make.height.equalTo(@44);
        }];
        
        //下面滚动的视图 实现上线联动
        self.mianScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,88, DEVICEWIDTH,DEVICEHEIGHT - 64)];
        self.mianScrollView.delegate = self;
        self.mianScrollView.contentSize = CGSizeMake(DEVICEWIDTH*self.headerView.headArray.count, 0);
        self.mianScrollView.pagingEnabled = YES;
        self.mianScrollView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:self.mianScrollView];
        
        //添加第一个视图
        self.gropuVC = [[GroupGoingController alloc]init];
        self.gropuVC.ID = self.ID;
        [self addChildViewController:self.gropuVC];
        self.gropuVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 46);
        [self.mianScrollView addSubview:self.gropuVC.view];
        
    }else if ([btn.titleLabel.text isEqualToString:@"结束阶段"]){
        [self.headerView removeFromSuperview];
        [self.mianScrollView removeFromSuperview];
        self.headerView = [[TitleScrollView alloc] initWithArray:@[@"项目总结",@"项目成果",@"资料归档",@"经验总结"]];
        self.index = 3;
        
        self.headerView.SelectDelegate = self;
        [self.view addSubview:self.headerView];
        [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bg1.mas_bottom);
            make.left.equalTo(self.view.mas_left);
            make.right.equalTo(self.view.mas_right);
            make.height.equalTo(@44);
        }];
        
        //下面滚动的视图 实现上线联动
        self.mianScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,88, DEVICEWIDTH,DEVICEHEIGHT - 64)];
        self.mianScrollView.delegate = self;
        self.mianScrollView.contentSize = CGSizeMake(DEVICEWIDTH*self.headerView.headArray.count, 0);
        self.mianScrollView.pagingEnabled = YES;
        self.mianScrollView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:self.mianScrollView];
        
        //添加第一个视图
        self.sumVC = [[SummaryViewController alloc]init];
        self.sumVC.ID = self.ID;
        [self addChildViewController:self.sumVC];
        self.sumVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 46);
        [self.mianScrollView addSubview:self.sumVC.view];
        
    }else{
        
        self.index = 4;
        
        //下面滚动的视图 实现上线联动
        self.mianScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,44, DEVICEWIDTH,DEVICEHEIGHT - 150)];
        self.mianScrollView.delegate = self;
        self.mianScrollView.contentSize = CGSizeMake(DEVICEWIDTH, 0);
        self.mianScrollView.pagingEnabled = YES;
        self.mianScrollView.backgroundColor = [UIColor redColor];
        [self.view addSubview:self.mianScrollView];
        
        //添加第一个视图
        self.lastVC = [[LastStageViewController alloc]init];
        self.lastVC.ID = self.ID;
        [self addChildViewController:self.lastVC];
        self.lastVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 150);
        [self.mianScrollView addSubview:self.lastVC.view];

    }


}

//UISrollView 代理方法

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    if (scrollView.contentOffset.x==DEVICEWIDTH) {
        if (self.index == 1) {
            //准备阶段
            if (self.InvesVC == nil) {
                self.InvesVC = [[InvestigateViewController alloc]init];
                self.InvesVC.ID = self.ID;
                [self addChildViewController:self.InvesVC];
                self.InvesVC.view.frame = CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.InvesVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.InvesVC.view];
            }
        }else if (self.index == 2){
        //实施阶段
            if (self.SchVC == nil) {
                self.SchVC = [[ScheduleController alloc] init];
                self.SchVC.ID = self.ID;
                [self addChildViewController:self.SchVC];
                self.SchVC.view.frame = CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.SchVC.view];
                
            }else{
                [self.mianScrollView addSubview:self.SchVC.view];
            }
        
        }else if (self.index == 3){
        //结束阶段
            if (self.PResVC == nil) {
                self.PResVC = [[PResultsViewController alloc] init];
                self.PResVC.ID = self.ID;
                [self addChildViewController:self.PResVC];
                self.PResVC.view.frame = CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.PResVC.view];
                
            }else{
            
                [self.mianScrollView addSubview:self.PResVC.view];

            }
        
        }else if(self.index == 4){
        //后续阶段
        
        }
        
    }else if(scrollView.contentOffset.x==DEVICEWIDTH*2){
        
        if (self.index == 1) {
            //准备阶段
            if (self.WorkTVC ==nil) {
                self.WorkTVC = [[WorkTeamViewController alloc]init];
                self.WorkTVC.ID = self.ID;
                [self addChildViewController:self.WorkTVC];
                self.WorkTVC.view.frame = CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.WorkTVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.WorkTVC.view];
            
            }
            
        }else if (self.index == 2){
        //实施阶段
            if (self.actiVC == nil) {
                self.actiVC = [[ActivityResultController alloc] init];
                self.actiVC.ID = self.ID;
                [self addChildViewController:self.actiVC];
                self.actiVC.view.frame = CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.actiVC.view];
                
            }else{
            
                [self.mianScrollView addSubview:self.actiVC.view];

            }

        }else if (self.index == 3){
        //结束阶段
            if (self.dataVC == nil) {
                self.dataVC = [[DataArchivingController alloc] init];
                self.dataVC.ID = self.ID;
                [self addChildViewController:self.dataVC];
                self.dataVC.view.frame = CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.dataVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.dataVC.view];
            
            }
            
        
        }else{
        //后续阶段
            
        
        }
        
    }else if(scrollView.contentOffset.x==DEVICEWIDTH*3){
        
        if (self.index == 1) {
            //准备阶段
            if (self.CompaVC ==nil) {
                self.CompaVC = [[CompanyRecruitViewController alloc]init];
                self.CompaVC.ID = self.ID;
                [self addChildViewController:self.CompaVC];
                self.CompaVC.view.frame = CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT-64);
                [self.mianScrollView addSubview:self.CompaVC.view];
                
            }else{
                [self.mianScrollView addSubview:self.CompaVC.view];
            }

        }else if (self.index == 2){
        //实施阶段
            if (self.GoVC == nil) {
                
                self.GoVC = [[GoHomeViewController alloc] init];
                self.GoVC.ID = self.ID;
                [self addChildViewController:self.GoVC];
                self.GoVC.view.frame = CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.GoVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.GoVC.view];

            }
            
        }else if (self.index == 3){
        //结束阶段
            if (self.ENDEXVC == nil) {
                self.ENDEXVC = [[ENDExperienceController alloc] init];
                self.ENDEXVC.ID = self.ID;
                [self addChildViewController:self.ENDEXVC];
                self.ENDEXVC.view.frame = CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.ENDEXVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.ENDEXVC.view];

            }
        
        }else{
        //后续阶段
            
        
        }
        
    }else if(scrollView.contentOffset.x==DEVICEWIDTH*4){
        
        if (self.index == 1) {
            //准备阶段
            if (self.PreVC ==nil) {
                self.PreVC = [[PreparedController alloc]init];
                self.PreVC.ID = self.ID;
                [self addChildViewController:self.PreVC];
                self.PreVC.view.frame = CGRectMake(DEVICEWIDTH*4, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.PreVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.PreVC.view];

            }
            
        }else if (self.index == 2){
        //实施阶段
            if (self.EvaVC == nil) {
                self.EvaVC = [[EvaluationExperienceController alloc] init];
                self.EvaVC.ID = self.ID;
                [self addChildViewController:self.EvaVC];
                self.EvaVC.view.frame = CGRectMake(DEVICEWIDTH*4, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.EvaVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.EvaVC.view];

            }
            
            
        }else if (self.index == 3){
        //结束阶段
        
        
        }else{
        //后续阶段
            
        
        }
        
     }
    else if(scrollView.contentOffset.x==DEVICEWIDTH*5){
    
           if (self.index == 1) {
            //准备阶段
            if (self.xqVC ==nil) {
                self.xqVC = [[xqzbViewController alloc]init];
                self.xqVC.ID = self.ID;
                [self addChildViewController:self.xqVC];
                self.xqVC.view.frame = CGRectMake(DEVICEWIDTH*5, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.xqVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.xqVC.view];

            }
            
        }
    
    }
    
              //btn tag ＝ i＋ 100
    [self.headerView changeBtnTitleColorWith:scrollView.contentOffset.x/DEVICEWIDTH+100];
}

//代理方法
-(void)selectControllerWithBtn:(UIButton *)btn{
    
    self.mianScrollView.contentOffset = CGPointMake(DEVICEWIDTH*(btn.tag - 100), 0);
    
    if(self.mianScrollView.contentOffset.x==0){
        
        if (self.index == 1) {
            //准备阶段
            if (self.proVC == nil) {
                
                self.proVC = [[ProjectViewController alloc]init];
                self.proVC.ID = self.ID;
                [self addChildViewController:self.proVC];
                self.proVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.proVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.proVC.view];
                
            }
            
        }else if(self.index == 2){
        //实施阶段
            if (self.gropuVC == nil) {
                self.gropuVC = [[GroupGoingController alloc] init];
                self.gropuVC.ID = self.ID;
                [self addChildViewController:self.gropuVC];
                self.gropuVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.gropuVC.view];
                
            }else{
                [self.mianScrollView addSubview:self.gropuVC.view];

            }
            
            
        }else if (self.index == 3){
        //结束阶段
            if (self.sumVC == nil) {
                self.sumVC = [[SummaryViewController alloc] init];
                self.sumVC.ID = self.ID;
                [self addChildViewController:self.sumVC];
                self.sumVC.view.frame = CGRectMake(0, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.sumVC.view];
            }else{
                [self.mianScrollView addSubview:self.sumVC.view];
            }
        
        
        }else{
        //后续阶段
        
        
        
        }
        
    }else if (self.mianScrollView.contentOffset.x==DEVICEWIDTH) {
        
        if (self.index == 1) {
            //准备阶段
            if (self.InvesVC == nil) {
                self.InvesVC = [[InvestigateViewController alloc]init];
                self.InvesVC.ID = self.ID;
                [self addChildViewController:self.InvesVC];
                self.InvesVC.view.frame = CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.InvesVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.InvesVC.view];
                
            }

        }else if(self.index == 2){
            //实施阶段
            if (self.SchVC == nil) {
                self.SchVC = [[ScheduleController alloc] init];
                self.SchVC.ID = self.ID;
                [self addChildViewController:self.SchVC];
                self.SchVC.view.frame = CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.SchVC.view];
            }else{
                [self.mianScrollView addSubview:self.SchVC.view];
            }
    
        }else if (self.index == 3){
            //结束阶段
            if (self.PResVC == nil) {
                self.PResVC = [[PResultsViewController alloc] init];
                self.PResVC.ID = self.ID;
                [self addChildViewController:self.PResVC];
                self.PResVC.view.frame = CGRectMake(DEVICEWIDTH, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.PResVC.view];
            }else{
                [self.mianScrollView addSubview:self.PResVC.view];
            }
            
        }else{
            //后续阶段
            
            
            
        }

        
        
    }else if(self.mianScrollView.contentOffset.x==DEVICEWIDTH*2){
        if (self.index == 1) {
            //准备阶段
            if (self.WorkTVC ==nil) {
                self.WorkTVC = [[WorkTeamViewController alloc]init];
                self.WorkTVC.ID = self.ID;
                [self addChildViewController:self.WorkTVC];
                self.WorkTVC.view.frame = CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.WorkTVC.view];
            }else{
                [self.mianScrollView addSubview:self.WorkTVC.view];
                
            }
        }else if(self.index == 2){
            //实施阶段
            
            if (self.actiVC ==nil) {
                self.actiVC = [[ActivityResultController alloc]init];
                self.actiVC.ID = self.ID;
                [self addChildViewController:self.actiVC];
                self.actiVC.view.frame = CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.actiVC.view];
            }else{
                [self.mianScrollView addSubview:self.actiVC.view];
                
            }
            
        }else if (self.index == 3){
            //结束阶段
            
            if (self.dataVC ==nil) {
                self.dataVC = [[DataArchivingController alloc]init];
                self.dataVC.ID = self.ID;
                [self addChildViewController:self.dataVC];
                self.dataVC.view.frame = CGRectMake(DEVICEWIDTH*2, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.dataVC.view];
            }else{
                [self.mianScrollView addSubview:self.dataVC.view];
                
            }
            
        }else{
            //后续阶段
            
            
            
        }
        
    }else if(self.mianScrollView.contentOffset.x==DEVICEWIDTH*3){
        if (self.index == 1) {
            //准备阶段
            if (self.CompaVC ==nil) {
                self.CompaVC = [[CompanyRecruitViewController alloc]init];
                self.CompaVC.ID = self.ID;
                [self addChildViewController:self.CompaVC];
                self.CompaVC.view.frame = CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.CompaVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.CompaVC.view];
                
            }
        }else if(self.index == 2){
            //实施阶段
            
            if (self.GoVC ==nil) {
                self.GoVC = [[GoHomeViewController alloc]init];
                self.GoVC.ID = self.ID;
                [self addChildViewController:self.GoVC];
                self.GoVC.view.frame = CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.GoVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.GoVC.view];
                
            }
            
        }else if (self.index == 3){
            //结束阶段
            if (self.ENDEXVC ==nil) {
                self.ENDEXVC = [[ENDExperienceController alloc]init];
                self.ENDEXVC.ID = self.ID;
                [self addChildViewController:self.ENDEXVC];
                self.ENDEXVC.view.frame = CGRectMake(DEVICEWIDTH*3, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.ENDEXVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.ENDEXVC.view];
                
            }
            
        }else{
            //后续阶段
            
            
            
        }
        
        
    }else if(self.mianScrollView.contentOffset.x==DEVICEWIDTH*4){
        if (self.index == 1) {
            //准备阶段
            if (self.PreVC ==nil) {
                self.PreVC = [[PreparedController alloc]init];
                self.PreVC.ID = self.ID;
                [self addChildViewController:self.PreVC];
                self.PreVC.view.frame = CGRectMake(DEVICEWIDTH*4, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.PreVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.PreVC.view];
                
            }
        }else if(self.index == 2){
            //实施阶段
            if (self.EvaVC ==nil) {
                self.EvaVC = [[EvaluationExperienceController alloc]init];
                self.EvaVC.ID = self.ID;
                [self addChildViewController:self.EvaVC];
                self.EvaVC.view.frame = CGRectMake(DEVICEWIDTH*4, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.EvaVC.view];
            }else{
                
                [self.mianScrollView addSubview:self.EvaVC.view];
                
            }
            
        }else if (self.index == 3){
            //结束阶段
   
            
        }else{
            //后续阶段
            
            
            
        }
        
        
        
    }
    
    
    
       else if(self.mianScrollView.contentOffset.x==DEVICEWIDTH*5){
    
           if (self.index == 1) {
            //准备阶段
            if (self.xqVC ==nil) {
                self.xqVC = [[xqzbViewController alloc]init];
                self.xqVC.ID = self.ID;
                [self addChildViewController:self.xqVC];
                self.xqVC.view.frame = CGRectMake(DEVICEWIDTH*5, 0, DEVICEWIDTH, DEVICEHEIGHT - 64);
                [self.mianScrollView addSubview:self.xqVC.view];
            }else{
            
                [self.mianScrollView addSubview:self.xqVC.view];

            }
            
        }
    
    }
    
}



@end













